<template>
  <div class='container'>
     <el-form :model="ruleForm" ref="ruleForm" label-width="100px" :rules="rules">
        <el-form-item label="" prop="chkState">
          <el-radio-group v-model="ruleForm.chkState">
            <el-radio :label="1">通过</el-radio>
            <el-radio :label="2">拒绝</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="" prop="chkRemarks">
           <el-input type="textarea" v-model="ruleForm.chkRemarks"></el-input>
        </el-form-item>
        <el-form-item>
           <el-button @click="$emit('closeDialog')">取消</el-button>
            <el-button type="primary" @click="checkSubmit">确认</el-button>
        </el-form-item>
      </el-form>
  </div>
</template>

<script>
import { choiceCheck } from '@/api/hmmm/questions'

export default {
  name: 'QuestionsCheck',
  props: {
    questionId: {
      type: Number,
      required: true
    }
  },
  data () {
    return {
      ruleForm: {
        chkState: 1,
        chkRemarks: ''
      },
      rules: {
        chkRemarks: [
          { required: true, trigger: 'change' }
        ]
      }
    }
  },
  methods: {
    // 点击确认提交审核结果
    async checkSubmit () {
      if (this.ruleForm.chkRemarks === '') return this.$message.warning('请输入审核意见')
      await choiceCheck({
        id: this.questionId,
        ...this.ruleForm
      })
      // console.log(res)
      this.$message.success('操作成功')
      // 关闭弹框
      this.$emit('closeDialog')
      // 触发父组件的关闭事件
      this.$emit('close')
    }
  }
}
</script>

<style scoped></style>
